"""implements the Sieve of Eratosthenes algorithm to find prime numbers"""

def primes(limit):
    candidates = {}.fromkeys(range(2, limit + 1),True)
    final = []
    unmark = 2
    while unmark <= limit:
        if candidates[unmark]:
            final.append(unmark)
            for key in range(unmark + 1, limit + 1):
                if key % unmark == 0:
                    candidates[key] = False
        unmark += 1
    return [key for key, value in candidates.items() if value]
        